package com.ali.controller;

import com.ali.common.StringUtil;
import com.ali.dto.PageInfo;
import com.ali.dto.Response;
import com.ali.dto.ReturnEnum;
import com.ali.dto.ShiInfo;
import com.ali.service.ShiService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/poetry/shi")
public class ShiController {
    @Resource
    private ShiService shiService;

    /**
     * 查询
     */
    @PostMapping(value = "/query")
    public Response<PageInfo<ShiInfo>> query(@RequestHeader Map<String, Object> header, @RequestBody Map<String, Object> param) {
        log.info("header：" + header);
        log.info("param：" + param);
        String pageNo = StringUtil.getString(param.get("pageNo"));
        String pageSize = StringUtil.getString(param.get("pageSize"));
        try {
            PageInfo<ShiInfo> pageInfo = shiService.query(pageNo, pageSize);
            return Response.success(pageInfo);
        } catch (Exception e) {
            return Response.fail(ReturnEnum.RC999.getCode(), e.getMessage());
        }
    }
}